Reescreva o Programa 8.2 de forma a utilizar for em vez de while.
Resposta:
##############################################################################
# Parte do livro Introdução à Programação com Python
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Quarta Edição - Março/2024 - ISBN 978-85-7522-886-9
#
# Site: https://python.nilo.pro.br/
#
# Arquivo: capitulo 08/exercicio-08-06.py
##############################################################################
def soma(L):
total = 0
for e in L:
total += e
return total
L = [1, 7, 2, 9, 15]
print(soma(L))
print(soma([7, 9, 12, 3, 100, 20, 4]))